package com.maimao.model.info;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;

import javax.annotation.RegEx;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @author MaoLin Wang
 * @date 2020/11/28 12:09 上午
 */
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
@Builder
@TableName("mm_address")
public class Address implements Serializable {

    private static final long serialVersionUID = -3253888793968258781L;

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @NotBlank(message = "请填写收货人")
    private String name;

    @TableField("province_id")
    @NotNull(message = "请选择收货地址")
    private Integer provinceId;

    @TableField("city_id")
    @NotNull(message = "请选择收货地址")
    private Integer cityId;

    @TableField("area_id")
    @NotNull(message = "请选择收货地址")
    private Integer areaId;

    @TableField(exist = false)
    private String province;
    @TableField(exist = false)
    private String city;
    @TableField(exist = false)
    private String area;
    @TableField("address")
    @NotBlank(message = "请填写详细地址")
    private String address;

    @NotBlank(message = "请填写手机号")
    @Pattern(regexp = "^((13[0-9])|(14[0,1,4-9])|(15[0-3,5-9])|(16[2,5,6,7])|(17[0-8])|(18[0-9])|(19[0-3,5-9]))\\d{8}$", message = "手机号格式不正确")
    private String mobile;

    @TableField("is_default")
    private Boolean isDefault;


    private String label;

    @TableField("zip_code")
    private String zipCode;


    @Override
    public String toString() {
        return "Address{" +
                "id=" + id +
                ", userId=" + userId +
                ", name='" + name + '\'' +
                ", provinceId=" + provinceId +
                ", cityId=" + cityId +
                ", areaId=" + areaId +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", area='" + area + '\'' +
                ", address='" + address + '\'' +
                ", mobile='" + mobile + '\'' +
                ", isDefault=" + isDefault +
                ", label='" + label + '\'' +
                ", zipCode='" + zipCode + '\'' +
                '}';
    }
}
